package com.sansecy.customview.drawArc;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.sansecy.customview.R;

import java.util.ArrayList;

public class DrawArcActivity extends AppCompatActivity {

    private DrawArcActivity mContext;

    public static void start(Context context) {
        Intent starter = new Intent(context, DrawArcActivity.class);
//    starter.putExtra();
        context.startActivity(starter);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_draw_arc);
        mContext = this;
        FullPieChart pieChart = findViewById(R.id.pieChart);
        pieChart.setStartAngel(-90);
        pieChart.setAnimationStartAngel(-90);
        pieChart.setDoAnimation(true);
        ArrayList<FullPieChart.PieData> pieData = new ArrayList<>();
        pieData.add(new FullPieChart.PieData(610, "蓝色", Color.parseColor("#1e8fe6")));
        pieData.add(new FullPieChart.PieData(0.0001f, "橘色", Color.parseColor("#ff9100")));
        pieData.add(new FullPieChart.PieData(0.0001f, "绿色", Color.parseColor("#43cf00")));
        pieChart.setPieData(pieData);

        ArrayList<FullBarChart.ChartData> chartData = new ArrayList<>();

        chartData.add(new FullBarChart.ChartData(40, "100.00", "10-1", "二"));
        chartData.add(new FullBarChart.ChartData(200, "200.00", "10-2", "三"));
        chartData.add(new FullBarChart.ChartData(300, "200.00", "10-3", "四"));
        chartData.add(new FullBarChart.ChartData(543, "300.00", "10-4", "五"));
        chartData.add(new FullBarChart.ChartData(700, "400.00", "10-5", "五"));
        chartData.add(new FullBarChart.ChartData(170, "500.00", "10-6", "五"));
        chartData.add(new FullBarChart.ChartData(683, "600.00", "10-7", "五"));

        FullBarChart fullBarChart = findViewById(R.id.barChart);
        fullBarChart.setHighlightColor(Color.parseColor("#e6516c"));
        fullBarChart.setDefaultColor(Color.parseColor("#ffa700"));
        fullBarChart.setTextColor(Color.parseColor("#4a4a4a"));
        fullBarChart.setTextVerticalSpacing(dpToPx(5));
        fullBarChart.setShowValues(true);
        fullBarChart.setJustShowHighlightValue(true);
        fullBarChart.setUseAnimation(true);
        fullBarChart.setDrawHighlightShadow(true);
        fullBarChart.setShadowColor(Color.parseColor("#f6f6f6"));
        fullBarChart.setDrawAllShadow(true);
        fullBarChart.setHighlightShadowColor(Color.parseColor("#E4E4E4"));
        fullBarChart.setAnimationDuration(3000);

//        fullBarChart.setShadowColor(Color.parseColor("#e5e5e5"));
        fullBarChart.setChartData(chartData);
        fullBarChart.performItemClick(chartData.size() - 1);

//        fullBarChart.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Calendar calendar = Calendar.getInstance();
//                Calendar selectedDate = Calendar.getInstance();
//                Calendar startDate = Calendar.getInstance();
//                startDate.set(2013, 1, 1);
//                Calendar endDate = Calendar.getInstance();
////                endDate.set(2020, 1, 1);
//                boolean[] type = {true, true, true, false, false, false};
//                TimePickerView pickerView = new TimePickerView.Builder(mContext, new TimePickerView.OnTimeSelectListener() {
//                    @Override
//                    public void onTimeSelect(Date date, View v) {//选中事件回调
//                    }
//                })
//                        .setType(type)//默认全部显示
//                        .setCancelText("Cancel")//取消按钮文字
//                        .setSubmitText("Sure")//确认按钮文字
//                        .setContentSize(18)//滚轮文字大小
//                        .setTitleSize(20)//标题文字大小
//                        .setTitleText("Title")//标题文字
//                        .setOutSideCancelable(false)//点击屏幕，点在控件外部范围时，是否取消显示
////                        .isCyclic(true)//是否循环滚动
//                        .setTitleColor(Color.BLACK)//标题文字颜色
//                        .setSubmitColor(Color.BLUE)//确定按钮文字颜色
//                        .setCancelColor(Color.BLUE)//取消按钮文字颜色
//                        .setTitleBgColor(0xFF666666)//标题背景颜色 Night mode
//                        .setBgColor(0xFF333333)//滚轮背景颜色 Night mode
////                        .setRange(calendar.get(Calendar.YEAR) - 20, calendar.get(Calendar.YEAR) + 20)//默认是1900-2100年
//                        .setDate(selectedDate)// 如果不设置的话，默认是系统时间*/
//                        .setRangDate(startDate, endDate)//起始终止年月日设定
//                        .setLabel("年", "月", "日", "时", "分", "秒")
//                        .isDialog(true)//是否显示为对话框样式
//                        .build();
//                pickerView.show();
//
//            }
//        });

    }


    int dpToPx(int dps) {
        return Math.round(getResources().getDisplayMetrics().density * dps);
    }
}
